package com.mbc.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mbc.dto.RoughAnimalInfoDTO;
import com.mbc.mapper.UserPublishedAnimalMapper;
import com.mbc.service.UserPublishedAnimalService;
import com.mbc.vo.DetailsAnimalInfoVO;
import com.mbc.vo.RoughAnimalInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;

/**
 * <p>
 * 用户发布流浪动物表 服务实现类
 * </p>
 *
 * @author suimeng
 * @since 2024-04-15
 */
@Service
public class UserPublishedAnimalServiceImpl implements UserPublishedAnimalService {
    @Autowired
    private UserPublishedAnimalMapper userPublishedAnimalMapper;

    /**
     * 查询粗糙动物信息
     *
     * @param roughAnimalInfoDTO 粗糙动物信息 DTO
     * @param page               页
     * @param size               大小
     * @return {@link ArrayList}<{@link RoughAnimalInfoVO}>
     */
    @Override
    public PageInfo<RoughAnimalInfoVO> getByRoughAnimalInfo(RoughAnimalInfoDTO roughAnimalInfoDTO, Integer page,
                                                             Integer size) {
        // 设置分页参数
        PageHelper.startPage(page, size);
        // 进行查询
        ArrayList<RoughAnimalInfoVO> list  = userPublishedAnimalMapper.getByRoughAnimalInfo(roughAnimalInfoDTO, LocalDateTime.now());
        return new PageInfo<>(list);
    }

    /**
     * 查询详细信息动物信息
     *
     * @param animalId 动物 ID
     * @return {@link DetailsAnimalInfoVO}
     */
    @Override
    public DetailsAnimalInfoVO getByDetailsAnimalInfo(Integer animalId) {
        DetailsAnimalInfoVO detailsAnimalInfoVO = userPublishedAnimalMapper.getByDetailsAnimalInfo(animalId);
        return detailsAnimalInfoVO;
    }


}
